import { Switch, Route, Redirect } from "react-router-dom"
import routes from './index'

function RouterView() {
    return (
        <Switch>
            {
                routes.map(item => {
                    if (item.path === '/') {
                        return <Redirect key={item.path} path="/" exact to="/home" />
                    } else {
                        return (
                          <Route key={item.path} path={item.path} component={item.component} />
                        )
                    }
                })
            }
        </Switch>
    )
}

export default RouterView